<div class="widget">
	<div class="box">
    	<h3>Employee Activity</h3>
        <ul class="list1">
        	<li>
            <span style="color:#090; float:left">< 5 mins</span>
            <span style="color:#F60">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;< 15 mins</span>
            <span style="color:#900; float:right; padding-right:5px;">> 15 mins</span>
            </li>
            <li style="text-align:center"></li>
        	<?php
			$sql = "SELECT * FROM `tbTimecard` WHERE `sDate` = :date ORDER BY `iID` ASC";
			$q = db::Query($sql, array(':date'=>date("n/j/Y")));
			while($row = $q->fetch()){
			?>
            	<?php
				$sql = "SELECT * FROM `tbEmployees` WHERE `iID` = :id";
				$q2 = db::Query($sql, array(':id'=>$row['iEmployeeID']));
				$r = $q2->fetch();
				if($row['sAction'] == "Punch In"){
				?>
                	<?php
					$temp = $r['s'.date("D")];
					$t = explode(" - ", $temp);
					$schIN = strtotime(date("n/j/Y")." ".$t[0]);
					if($row['iTimeStamp'] <= $schIN + 300){
						$color = "#090";
					}elseif($row['iTimeStamp'] <= $schIN + 900){
						$color = "#F60";
					}else{
						$color = "#900";
					}
					?>
        			<li style="text-align:center; <?php if(!isset(${$r['sFname']})){ ?>color:<?php echo $color ?><?php } ?>"><?php echo "<span style='float:left'>".$r['sFname']."</span> IN <span style='float:right; padding-right:5px;'>".date("g:i A", $row['iTimeStamp'])."</span>" ?></li>
                    <?php ${$r['sFname']} = true; ?>
            	<?php }else{ ?>
                	<?php
					$temp = $r['s'.date("D")];
					$t = explode(" - ", $temp);
					$schOUT = strtotime(date("n/j/Y")." ".$t[0]);
					if($row['iTimeStamp'] >= $schOUT - 300){
						$color = "#F60";
					}else{
						$color = "#090";
					}
					?>
            		<li style="text-align:center;"><?php echo "<span style='float:left'>".$r['sFname']."</span> OUT <span style='float:right; padding-right:5px;'>".date("g:i A", $row['iTimeStamp'])."</span>" ?></li>
            	<?php } ?>
            <?php } ?>
		</ul>
	</div>
</div>